<template>
	<user-selector
		ref="userSelector"
		:mode="true"
		:userInfoList="userInfoList"
		@success="handleUserSelect"
		@closed="handleClose"
	/>

	<el-button @click="showSelector">选择人员</el-button>

	<div v-for="user in selectedUsers" :key="user.accountId">
		{{ user.userName }} ({{ user.deptName }})
	</div>

	<div>
		<button @click="init">编辑详情</button>
	</div>
</template>
<script>
// import  from '@/components/UserSelector.vue';
import UserSelector from '@/views/module/selectUserDialogGetUserDeptId.vue';
export default {
	components: { UserSelector },
	data() {
		return {
			selectedUsers: [],
			userInfoList: [],
		}
	},
	created() {

	},
	methods: {
		 init() {
			this.userInfoList = [
				{id:1,userName:'admin'},{id:11,userName:'001'}
			];
			 console.log('userInfoList',this.userInfoList)
		},
// 显示选择器
		showSelector() {
			this.$refs.userSelector.selectOrgUser();
		},

// 接收选择结果
		handleUserSelect(users) {
			this.selectedUsers = users;
			console.log('已选人员:', users);
			/*
			返回数据格式：
			[
			{
			accountId: '1001',
			userName: '张三',
			deptId: '101',
			deptName: '技术部'
			},
			...
			]
			*/
		},

// 对话框关闭回调
		handleClose() {
			console.log('选择器已关闭');
		}
	}
}
</script>
